<style>
    .layui-form-label{
        width: 120px!important;
    }
</style>
<div style="margin: 5% 5%;">
  <form class="layui-form" action="" lay-filter="example" id="fff">

    <div class="layui-form-item ">
      <div class="layui-inline">
        <label class="layui-form-label">分组名称:</label>
        <div class="layui-input-inline">
          <input type="text"  name="groupName" autocomplete="off" class="layui-input" value="">
        </div>
      </div>
    </div>

    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">分组状态:</label>
        <div class="layui-input-inline">
          <select name="groupStatus" >
            <option value="启用" >启用</option>
            <option value="禁用" >禁用</option>
          </select>
        </div>
      </div>
    </div>

    <div class="layui-form-item " style="display: none;">
      <div class="layui-inline">
        <div class="layui-input-inline">
          <input type="text" name="groupStationId" class="layui-input" value="">
        </div>
      </div>
    </div>

    <div class="layui-form-item">
      <div class="layui-input-block">
        <button id="demo11" type="button" class="layui-btn" lay-submit lay-filter="demo11">新增</button>
      </div>

      <div class="layui-input-block">
      </div>
    </div>

  </form>
</div>
<script>

  var local_store = layui.data("local_store");
  var local = local_store.token;
  var $ = layui.$;


  layui.use(['form'], function(){
            var form = layui.form;
            form.render();
          }
  );


  $("#demo11").click(function () {
    var formdata = $("#fff").serialize();
    $.ajax({
      url: "/admin/group/add/group",
      type: 'get',
      dataType: "JSON",
      contentType:"application/json;charset=utf-8",
      data:formdata,
      // beforeSend: function () {
      //   this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
      // },
      success: function (res) {
        if (res.code == 500) {
          layer.msg("新增失败\t"+res.data, {icon: 5,time: 1000});//失败的表情
          return;
        } else if (res.code == 200) {
          layer.msg("新增成功", {
            icon: 6,//成功的表情
            time: 1000 //1秒关闭（如果不配置，默认是3秒）
          }, function () {
            location="#/exception/404";
            return false;
          });
          window.setTimeout(function () {
            //location.reload();
          },1000)
        }
      },
      complete: function () {
        layer.close(this.layerIndex);
      },
    });
  });







  function GetRequest() {
    var url = decodeURI(location.search); //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {
        theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
      }
    }
    return theRequest;
  }

  var json=GetRequest();
  $("input[name='groupStationId']").attr("value",json.id)

</script>